package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.tool.btn.SevenTwoChangesBtn;
import com.tool.image.ImageMixDeal;
import org.come.model.Eshop;
import org.come.until.CutButtonImage;
import org.come.until.DeviceEshopUntil;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.TaoBaoBtn;
import com.tool.btn.TextBtn;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import com.tool.tcp.Sprite;
import com.tool.tcp.SpriteFactory;
import com.updateNew.MyIsif;

/**
 * 商城主面板
 * <p>
 * Title : TaobaoCourtMainJpanel
 * </p>
 *
 * @author : HGC
 * @date : 2019年7月17日 上午9:38:52
 * @version : 1.0.0
 */
public class TaobaoCourtMainJpanel extends JPanel {

    /** 7-17-HGC-start */
    // 充值1 商城2 锦绣3 限购4 周卡5 月卡6 基金7
    // private String[] menuNames = { "充值", "商城", "锦绣", "限购", "累充", "月卡", "基金"
    // };
    // /** 商城 锦绣 每日限购 周卡 月卡 充值 */
    // private TaoBaoBtn[] menuBtn = new TaoBaoBtn[7];
    /**
     * 商城shopMenuBtn<br>
     * 锦绣taobaoMenuBtn<br>
     * 限购restrictionMenuBtn<br>
     * 月卡 monthCardBtn<br>
     * VIPvipMenuBtn<br>
     */
    //商城新增加 shopHomePage,shopFlyBtn,

    private TaoBaoBtn shopHomePage,
            shopMenuBtn,//商城按钮
            shopFlyBtn,
            taobaoMenuBtn,//锦绣按钮
            restrictionMenuBtn,
            monthCardBtn,//月卡
            liangCardBtn,//商城靓号
            vipMenuBtn;//VIP
    private JLabel jadeLab, // 仙玉背景框
            jadeNum,  // 仙玉数量
            Money; // 仙玉数量
    // 充值
    private TextBtn changeXY;
    private SevenTwoChangesBtn selectBtn;//搜索按钮
    /** 7-17-HGC-end */
    // private RoleOperationPanelBtn applyMenu;// 充值按钮

    private TaobaoCourtCardJpanel taobaoCourtCardJpanel;

    //新增加tcp
    static Sprite tcp = SpriteFactory.VloadSprite("inkImg/number/b8/topzj.tcp", null);//特效路径
    static Sprite tcp2 = SpriteFactory.VloadSprite("inkImg/number/b8/runn.tcp", null);//特效路径

    private ImageIcon icon = null;
    static {
        if (tcp == null) {
            tcp = tcp;

        }
    }
    static {
        if (tcp2 == null) {
            tcp2 = tcp2;

        }
    }

    //新增加tcp



    public TaobaoCourtMainJpanel(){
            // 关闭按钮事件
            this.setPreferredSize(new Dimension(802, 538));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);
            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/number/b8/s74.png", 1, 39);
            offBtn.setBounds(790 - 15, 5, 21, 21);
            this.add(offBtn);

            // applyMenu = new RoleOperationPanelBtn("skin/8100226/button/2.png", 1, "充值",
            // null, null, null, null);
            // applyMenu.setBounds(219, 433, 85, 24);
            // this.add(applyMenu);
            taobaoCourtCardJpanel = new TaobaoCourtCardJpanel();
            // this.add(TaobaoCourtCardJpanel.getTaobaoCourtCardJpanel());

            /** 7-17-HGC-start */
            // for (int i = 0; i < menuBtn.length; i++) {
            // menuBtn[i] = new TaoBaoBtn("skin/8100226/button/6.png", 1, menuNames[i], i
            // + 1, this);
            // menuBtn[i].setBounds(60 + i * 72, 19, 70, 35);
            // menuBtn[i].setOpaque(false);
            // this.add(menuBtn[i]);
            // }
            // try {
            // menuBtn[1].setIcons(CutButtonImage.cuts("skin/8100226/button/5.png"));
            // } catch (Exception e) {
            // // TODO Auto-generated catch block
            // e.printStackTrace();
            // }
        //商城新增加
        getShopHomePage();
        getShopFlyBtn();
        //商城新增加
            getShopMenuBtn();
            getTaobaoMenuBtn();
            // getRestrictionMenuBtn();
            getMonthCardBtn();
//            getVipMenuBtn();//会员栏
            this.add(getJadeNum());
            this.add(getMoney());
//            getChangeXY();
//        getLiangCardBtn();//靓号
            this.add(taobaoCourtCardJpanel);
        }
    /** 7-17-HGC-end */
    public TaoBaoBtn getLiangCardBtn() {
        if (liangCardBtn == null) {
            liangCardBtn = new TaoBaoBtn("inkImg/number/b8/liang1.png", 1, "", 8, this);
            liangCardBtn.setBounds(23, 60 + 5 * 35, 110, 35);
            this.add(liangCardBtn);
        }
        return liangCardBtn;
    }

    /**
     * 通过类别获得特效等的集合
     */
    public static List<Eshop> returnlEshops(int type) {
        List<Eshop> lEshops = new ArrayList<Eshop>();
        if (type == 11) {
            lEshops = DeviceEshopUntil.getShopingTX();
        } else if (type == 12) {
            lEshops = DeviceEshopUntil.getShopingZS();
        } else if (type == 13) {
            lEshops = DeviceEshopUntil.getShopingZJ();
        }

        return lEshops;
    }

    // public RoleOperationPanelBtn getApplyMenu() {
    // return applyMenu;
    // }
    //
    // public void setApplyMenu(RoleOperationPanelBtn applyMenu) {
    // this.applyMenu = applyMenu;
    // }

    public ImageIcon getIcon() {
        return icon;
    }

    public void setIcon(ImageIcon icon) {
        this.icon = icon;
    }

    public TaobaoCourtCardJpanel getTaobaoCourtCardJpanel() {
        return taobaoCourtCardJpanel;
    }

    public void setTaobaoCourtCardJpanel(TaobaoCourtCardJpanel taobaoCourtCardJpanel) {
        this.taobaoCourtCardJpanel = taobaoCourtCardJpanel;
    }

    //-----------------------------------------

    //商城新增加
     public TaoBaoBtn getShopHomePage() {
          if (shopHomePage == null) {
                 shopHomePage = new TaoBaoBtn("inkImg/number/b8/shouye.png", 1, "", 1, this);
                shopHomePage.setBounds(23, 60, 110, 35);
                 this.add(shopHomePage);
               }

           return shopHomePage;
          }

      public void setShopHomePage(TaoBaoBtn shopHomePage) {
        this.shopHomePage = shopHomePage;
      }

    //商城新增加



    public TaoBaoBtn getShopMenuBtn() {
            if (shopMenuBtn == null) {
                shopMenuBtn = new TaoBaoBtn("inkImg/number/b8/zonghe.png", 1, "", 2, this);
                shopMenuBtn.setBounds(23, 60 + 1 * 35, 110, 35);
                this.add(shopMenuBtn);
            }

        return shopMenuBtn;
    }

    public void setShopMenuBtn(TaoBaoBtn shopMenuBtn) {
        this.shopMenuBtn = shopMenuBtn;
    }

    //商城新增加
    public TaoBaoBtn getShopFlyBtn() {
        if (shopFlyBtn == null) {
            shopFlyBtn = new TaoBaoBtn("inkImg/number/b8/Fly.png", 1, "", 4, this);
            shopFlyBtn.setBounds(23, 60 + 2 * 35, 110, 35);
            this.add(shopFlyBtn);
        }

        return shopFlyBtn;
    }

    public void setShopFlyBtn(TaoBaoBtn shopFlyBtn) {
        this.shopFlyBtn = shopFlyBtn;
    }

    //商城新增加


    public TaoBaoBtn getTaobaoMenuBtn() { {
            if (taobaoMenuBtn == null) {
                taobaoMenuBtn = new TaoBaoBtn("inkImg/number/b8/jinxiu.png", 1, "", 3, this);
                taobaoMenuBtn.setBounds(23, 60 + 3 * 35, 110, 35);
                this.add(taobaoMenuBtn);
            }
        }
        return taobaoMenuBtn;
    }

    public void setTaobaoMenuBtn(TaoBaoBtn taobaoMenuBtn) {
        this.taobaoMenuBtn = taobaoMenuBtn;
    }


    public TaoBaoBtn getMonthCardBtn() {
        if (monthCardBtn == null) {
            monthCardBtn = new TaoBaoBtn("inkImg/number/b8/monthly.png", 1, "", 6, this);
            monthCardBtn.setBounds(23, 60 + 4 * 35, 110, 35);
            this.add(monthCardBtn);
        }

        return monthCardBtn;
    }

    public void setMonthCardBtn(TaoBaoBtn monthCardBtn) {
        this.monthCardBtn = monthCardBtn;
    }

    public TaoBaoBtn getVipMenuBtn() {

        if (vipMenuBtn == null) {
            vipMenuBtn = new TaoBaoBtn("inkImg/number/b8/VIP.png", 1, "", 7, this);
            vipMenuBtn.setBounds(23, 60 + 5 * 35, 110, 35);
            this.add(vipMenuBtn);
        }

        return vipMenuBtn;
    }

    public void setVipMenuBtn(TaoBaoBtn vipMenuBtn) {

        this.vipMenuBtn = vipMenuBtn;
    }




//-----------------------------------------



    public void setRestrictionMenuBtn(TaoBaoBtn restrictionMenuBtn) {
        this.restrictionMenuBtn = restrictionMenuBtn;
    }



    public void setJadeLab(JLabel jadeLab) {
        this.jadeLab = jadeLab;
    }


    @Override
    protected void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        this.setLayout(null);
        this.setPreferredSize(new Dimension(802, 538));
        this.setOpaque(false);
        super.paintComponent(g);
            if (icon == null) {
                icon = CutButtonImage.getImage("inkImg/number/b8/taobaobjx.png", 802, 538);
            }
            g.drawImage(icon.getImage(), 0, 0, 802, 538, null);
            g.setFont(UIUtils.TEXT_HURT2);
            g.setColor(new Color(187, 165, 75));

        Money.setText(RoleData.getRoleData().getLoginResult().getMoney().toString()+"");

    }
    /** 当前人物仙玉数量 */

    public JLabel getJadeNum() {
            if (jadeNum == null) {
                jadeNum = new JLabel(RoleData.getRoleData().getLoginResult().getCodecard() + "");
                jadeNum.setBounds(555, 16 + 2, 95, 15);
                jadeNum.setOpaque(false);
                jadeNum.setForeground(Color.white);
                jadeNum.setFont(UIUtils.TEXT_COM_FONT);
            }
        return jadeNum;
    }

    public void setJadeNum(JLabel jadeNum) {
        this.jadeNum = jadeNum;
    }


    public JLabel getMoney() {
        if (Money  == null) {
            Money = new JLabel(RoleData.getRoleData().getLoginResult().getMoney().toString()+"");
            Money.setBounds(679, 16 + 2, 75, 15);
            Money.setOpaque(false);
            Money.setForeground(Color.white);
            Money.setFont(UIUtils.TEXT_COM_FONT);
        }
        return Money;
    }

    public void setMoney(JLabel Money) {
        this.Money = Money;
    }


//    public TextBtn getChangeXY() {
//        if (changeXY == null) {
//            // 充值按钮 (TextBtn 中 caozuo == 1)
//            changeXY = new TextBtn("inkImg/number/b8/gouwu1.png", 1, "", 888);
//            changeXY.setBounds(750, 15, 25, 20);
//            this.add(changeXY);
//
//            // 添加鼠标事件监听器
//            changeXY.addMouseListener(new java.awt.event.MouseAdapter() {
//                public void mouseEntered(java.awt.event.MouseEvent evt) {
//                    changeXY.setToolTipText("在线充值");
//                }
//            });
//        }
//        return changeXY;
//    }

//    public void setChangeXY(TextBtn changeXY) {
//        this.changeXY = changeXY;
//    }


    //新增加tcp
    @Override
    public void paint(Graphics g) {

        tcp.updateToTime(ImageMixDeal.userimg.getTime(), 0);
        tcp2.updateToTime(ImageMixDeal.userimg.getTime(), 0);
        super.paint(g);
        tcp.draw(g, 0, 0);
        tcp2.draw(g, 10, 430);
    }

//新增加tcp




}
